<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}jp/msg.css" />
<link rel="stylesheet" href="${aier_css_url}jc/chosen.css">
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css">
<link rel="stylesheet" href="${aier_css_url}social/module/icon.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/btn.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/userCenter/usercenter.css">
<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
</head>
<body>

	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user"
		executeResult="true"></s:action>

	<div class="window-content">

		<!-- 正文 -->
		<div class="wrap wrap-user-center">

			<!-- userCenter topBg -->
			<s:action name="uccomm_userCenterHTitle" namespace="/user"
				executeResult="true"></s:action>
			<!-- main -->

			<div class="wrap-main">
				<!-- 中间导航栏 -->
				<div class="wrap-main-nav">
					<ul class="float-list clearfix">
						<li><a class="user-center-tag"
							href="${aier_url}user/uccomm_userCenter.shtml?in_type=1&in_uid=${in_uid}">我的内容</a>
						</li>
						<li><a class="user-center-tag"
							href="${aier_url}user/uccomm_userInfo.shtml?in_type=2&in_uid=${in_uid}">我的资料</a>
						</li>
						<s:if test="%{isOther==0}">  
                            <li><a class="user-center-tag" target="_blank" href="${aier_url}user/usermyfollow.shtml?in_uid=${in_uid}">关注/粉丝</a>
                        </li>
                        </s:if>
						<li><a class="user-center-tag current"
							href="${aier_url}user/uccomm_userAlbum.shtml?in_type=3&in_uid=${in_uid}">我的相册</a>
						</li>
						<li><a class="user-center-tag last-has-border"
							href="${aier_url}user/uccomm_userLike.shtml?in_type=4&in_uid=${in_uid}">我的收藏</a>
						</li>
					</ul>
				</div>

				<!-- 主区域  相册 -->
				<div class="wrap-main-column clearfix">
				    <s:if test="%{isOther==0}">  
                         <div class="upload-photo-bar">
	                        <a href="###" class="btn-orange-2" id="btnUploadAlbum"><span>上传照片</span>
	                        </a>
	                    </div>  
                    </s:if>
					
					<div id="uptListDiv" class="photo-album-list">
						
					</div>

				</div>



			</div>

			<!-- 返回顶部 -->
			<s:action name="userhomecomm_backToTop" namespace="/user"
				executeResult="true"></s:action>
			<!-- end 返回顶部 -->
		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>


	<!-- 相册图片上传dialog -->
	<div id="dialogUploadAlbum" class="upload-albumn-picture"
		style="display: none;" title="上传图片到相册">
		<div class="board">
			<!-- 选择上传相册 -->
			<div class="select-bar clearfix	">
				<div class="upload-to">上传到：</div>
				<div id="uaUptidDiv" class="select-albumn">
					
				</div>

				<div class="create-new">
					<a href="javascript:void(0);" id="btnCreateAlbum"><span>新建相册</span>
					</a>
					<!-- 创建新相册弹出层 -->
					<div id="dialogCreateAlbum" title="创建新相册" style="display:none">
						<label> 请输入相册名: <input type="text" id="newAlbumName" /> </label>
					</div>
				</div>
			</div>
			<!-- /选择上传相册 -->

			<!-- 上传图片面板 -->
			<div class="upload-board-1">


				<!-- 点击上传 -->
				<!-- <div class="start-upload-btn">点击上传图片</div>-->
				<!-- /点击上传 -->


				<!-- 预览模式 -->
				<!-- <div class="upload-temp-preview" style="display:none;"></div>-->
				<!-- /预览模式 -->
				<img class="area-img" id="areaImg" style="display: none;">
				<div id="reselect2" onclick="delfile2();" class="start-upload-btn"
					style="cursor: pointer;display: none;">重新选择</div>
				<input class="input_opacity" type="file" id="file2" name="file2">
				<label id="upPic2" class="start-upload-btn" style="cursor:pointer;"
					for="file2"><a class="start-upload-btn" id="b_selfile"
					href="javascript:;">点击上传图片 </a> </label>
			</div>
			<!-- /上传图片面板 -->
		</div>
	</div>
</body>

<script type="text/javascript">
    
	$('#dialogUploadAlbum')
			.dialog(
					{
						//背景变暗
						modal : true,
						autoOpen : false,
						show : "fade",
						hide : "fade",
						width : "530",
						height : "660",
						buttons : {
							"确定" : function() {
								if(isnull($("#uaUptid").val())){
									$().message("请先新建相册");
									return
								}
								var fun = function(data) {
									if(1==data.s){
										
										$('#file2').show();
										$('#upPic2').show();
										$('#areaImg').hide();
										$('#reselect2').hide();
										
										imgName = "";
										loadImgType();
										$().message("照片添加成功");
										$('#dialogUploadAlbum').dialog("close");
									}
								};
								exeAjax(
										ajaxUrl("${aier_url}${aier_urijs}uccomm_addUserPhotoImg${aier_suffix}"),
										fun, {
											"uptid" : $("#uaUptid").val(),
											"img" : imgName
										});

							},
							"取消" : function() {
								$(this).dialog("close");
							}
						}
					});

	$('#btnUploadAlbum').click(function() {
		$('#dialogUploadAlbum').dialog('open');
	});

	function openTag() {
		if ($(this).hasClass('current')) {
			//do nothing
		} else {
			$(this).addClass('current').nextAll().removeClass('current');
			$(this).prevAll().removeClass('current');
			$('.custom-cover-box,.classic-cover-box').removeClass('open');
		}
		;
		if ($('.classic-cover-btn').hasClass('current')) {
			$('.classic-cover-box').addClass('open');
		} else {
			$('.custom-cover-box').addClass('open');
		}

	};

	$('.classic-cover-btn,.custom-cover-btn').click(openTag);

	// 
	$('.cover-setting-btn').click(function() {
		$('.window-el-cov-set').css('display', 'block');
	});
	$('.cov-set-cancel-btn').click(function() {
		$('.window-el-cov-set').css('display', 'none');
	});
	// 
	$('.submit-btn').click(function() {
		location.reload();
	});

	//  选择相册

	function openAlbumnList() {
		if ($('.all-options').hasClass('open')) {
			$('.all-options').removeClass('open');
		} else {
			// ajax
			$('.all-options').addClass('open');
		}
	}

	$('.select-btn').click(openAlbumnList);

	// 创建相册	

	$('#dialogCreateAlbum')
			.dialog(
					{
						//背景变暗
						modal : true,
						autoOpen : false,
						show : "fade",
						hide : "fade",
						width : "320",
						height : "240",
						buttons : {
							"确定" : function() {
								if(isnull($("#newAlbumName").val())){
									$().message("请输入相册名称！");
									return
								}
								var fun = function(data) {
										if(1==data.s){
											$().message("创建相册成功！");
											$("#newAlbumName").val("");
											loadImgType();
											$('#dialogCreateAlbum').dialog("close");
										}
								};
								exeAjax(
										ajaxUrl("${aier_url}${aier_urijs}uccomm_addUserPhotoType${aier_suffix}"),
										fun, {
											"pname" : $("#newAlbumName").val(),
										    "in_uid" : in_uid
										});

							},
							"取消" : function() {
								$(this).dialog("close");
							}
						}
					});

	$('#btnCreateAlbum').click(function() {
		$('#dialogCreateAlbum').dialog('open');
	});

	

	// 上传文件
	var imgName = "";
	function upfile2() {
		var pName = $("#file2").val().split("\\")[2];
		if (isnull(pName)) {
			$().message("请选择图片！");
			return;
		}
		var pname1 = pName.substring(pName.lastIndexOf('.')).toLowerCase();
		try {
			$
					.ajaxFileUpload({
						url : "${aier_url}${aier_urijs}uccomm_uploadUserPhotoImg${aier_suffix}?photoName="
								+ pname1,
						secureuri : false,
						fileElementId : 'file2',
						dataType : 'json',
						success : function(data, status) {
							$('#file2').hide();
							$('#upPic2').hide();
							$('#areaImg').show();
							$('#reselect2').show();
							$('#areaImg').attr("src", "${get_gallery_url}origin/" + data.img);
							imgName = data.img;
						},
						error : function(data, status, e) {
							$().message("服务器连接超时");
						}
					});
		} catch (e) {
			$().message("服务器连接超时");
		}
		
	}
	
	//重新选择图片
	function delfile2() {
		var fun = function(data) {
			if (data.s == 1) {
				$('#file2').show();
				$('#upPic2').show();
				$('#areaImg').hide();
				$('#reselect2').hide();
				
				imgName = "";
			} else {
				$().message("删除失败，请稍后再试！");
			}
		};
		exeAjax(
				ajaxUrl("${aier_url}${aier_urijs}uccomm_deleteUploadImg${aier_suffix}"),
				fun, {
					"img" : imgName
				});
	}

	$("#file2").live('change', function() {
		upfile2();
	});
	
	
	//加载相册类别
	function loadImgType(){
		var fun = function(data) {
			
			if(!isnull(data.uptList)){
				var uptList = data.uptList;
				
				var temp = "<select id='uaUptid' class='chosen'>";
				var te = "<ul class='float-list clearfix list'>";
				
				for(var i=0;i<uptList.length;i++){
					temp +="<option value="+uptList[i].uptid+">"+uptList[i].pname+"</option>";
					te +="<li><div class='album-cover'><div class='bottom-layer'><div class='cover-layer'><a style='width:100%;height:100%' href='${aier_url}user/uccomm_userAlbumIn.shtml?in_type=5&uptid="+uptList[i].uptid+"&in_uid="+uptList[i].uid+"'><img style='width:100%;height:100%' src='${get_gallery_url}small/"+uptList[i].img+"'> </a></div></div></div><div class='album-title'><a href='${aier_url}user/uccomm_userAlbumIn.shtml?in_type=5&uptid="+uptList[i].uptid+"'>"+uptList[i].pname+"</a> <span>(共"+uptList[i].num_img+"张)</span></div></li>";

				}
				temp += "</select>";
				te +="</ul>";
				$("#uaUptidDiv").html(temp);
				$(".chosen").chosen();
				$("#uptListDiv").html(te);
			}else{
				$("#uaUptidDiv").html("");
				$("#uptListDiv").html("");
			}
		};
		exeAjax(
				ajaxUrl("${aier_url}${aier_urijs}uccomm_searchUserImgtype${aier_suffix}"),
				fun, {
					"in_uid" : "${in_uid}"
				});
	}
	loadImgType();
</script>
</html>